Validation #2: Simple E-mail Check

This script will not submit unless the text field contains an at-sign (@).

Discussion

This form's onSubmit event calls the function validate(), which ensures that the text field contains an @ sign.
function validate()
{
    if ((document.forms[0].F1.value.length == 0) ||
       (document.forms[0].F1.value.indexOf('@') < 0))
    {
        alert('You must enter an e-mail address')
        return false
    }
    else 
        return true
}
Copyright ©2000 by Charles River Media, All Rights Reserved